<?php
namespace  zhtfrontend\components\services\goods;

use common\components\helpers\Fun;
use zhtfrontend\models\datas\Goods;
use zhtfrontend\models\datas\GoodsPrice;
use yii\base\Action;
use yii\web\BadRequestHttpException;

class SetListAction extends Action{


    public function run(){
        $role=isset(\Yii::$app->user->identity->role)?\Yii::$app->user->identity->role:'';
        $goods_id= \Yii::$app->request->get('id');
        if($goods_id == null){
            throw new BadRequestHttpException(\Yii::t('frontend', '数据错误！'));
        }
        $goods = Goods::findOne($goods_id);
        if($goods == null){
            throw new BadRequestHttpException(\Yii::t('frontend', '数据错误！'));
        }
        $goodsprice=GoodsPrice::find()->where(['goods_id'=>$goods_id])->orderBy('id DESC')->all();
        $goodsprice = Fun::asArray($goodsprice,['operate']);
//        print_r($goodsprice);die;
        return $this->controller->render('@zhtfrontend/components/services/goods/setlist.php',['data'=>$goodsprice,'model'=>$goods]);
    }


}